Virtual Disk Migration Method, Apparatus and Device, and Readable Storage Medium

ABSTRACT

A virtual disk migration method, apparatus and device, and a readable storage medium. Said method comprises: when a data change occurs in a cluster, updating the label of the cluster in a binary table to a first target value (S 101 ); copying data in the cluster to a second data center, and updating the first target value to a second target value (S 102 ); and upon reception of an instruction for migrating a virtual machine to the second data center (S 103 ), controlling the virtual machine to stop operating, querying the first target value in the binary table, and migrating data in the cluster corresponding to the queried first target value to the second data center (S 104 ). A part of data is copied to a second data center in advance on the basis of a binary table, and when a virtual machine is migrated, only the other part of data needs to be migrated, thereby reducing the data migration amount and migration time, and improving the migration efficiency of a virtual disk and a virtual machine.

This application claims priority to Chinese patent application No.201910838357.X, entitled “VIRTUAL DISK MIGRATION METHOD, APPARATUS ANDDEVICE, AND READABLE STORAGE MEDIUM”, filed with the China NationalIntellectual Property Administration on Sep. 5, 2019, the disclosure ofwhich is hereby incorporated by reference in its entirety.

TECHNICAL FIELD

The present application relates to the field of computer technologies,and in particular, to a virtual disk migration method, apparatus anddevice, and a readable storage medium.

BACKGROUND ART

In the prior art, a backup disk is generally disposed at a source end.The backup disk is used to back up data in a virtual disk correspondingto a virtual machine operating at the source end. When it is necessaryto migrate the virtual machine at the source end to a destination end,all the data in the backup disk is directly migrated to the destinationend, so as to complete the migration of the virtual disk correspondingto the virtual machine and implement the migration of the virtualmachine accordingly As can be seen, in such an existing migrationmethod, all the data in the backup disk needs to be migrated to thedestination end at once. In this case, the data migration amount isrelatively large, resulting in an increased migration time and reducedmigration efficiency of a virtual disk and a virtual machine.

Therefore, how to improve the migration efficiency of virtual disks is aproblem to be resolved by a person skilled in the art.

SUMMARY OF THE INVENTION

In view of this, an objective of the of the present application is toprovide a virtual disk migration method, apparatus and device, and areadable storage medium, thereby improving the migration efficiency ofvirtual disks. Specific solutions of the present application are asfollows:

According to a first aspect, the present application provides a virtualdisk migration method, applied to a first data center, a source virtualdisk corresponding to a virtual machine operating in the first datacenter being divided into a plurality of clusters, the method including:

when a data change occurs in a cluster, updating the label of thecluster in a binary table to a first target value; copying data in thecluster to a second data center, and updating the first target value toa second target value; and

if an instruction for migrating the virtual machine to the second datacenter is received, controlling the virtual machine to stop operating,querying the first target value in the binary table, and migrating datain the cluster corresponding to the queried first target value to thesecond data center.

Preferably, the second data center is a disaster recovery center of thefirst data center; and if a corresponding backup virtual disk isdisposed for a disaster recovery virtual disk in the second data center,the copying data in the cluster to a second data center includes:copying the data in the cluster to the backup virtual disk, where thedisaster recovery virtual disk is disposed in the second data center andis configured to perform disaster recovery on data in the source virtualdisk; and correspondingly, the migrating data in the clustercorresponding to the queried first target value to the second datacenter includes: migrating data in the cluster corresponding to thequeried first target value to the backup virtual disk.

Preferably, after the migrating data in the cluster corresponding to thequeried first target value to the backup virtual disk, the methodfurther includes:

controlling, by the second data center, the virtual machine to operateon the basis of the backup virtual disk.

Preferably, before the controlling the virtual machine to operate on thebasis of the backup virtual disk, the method further includes:

migrating a memory resource of the virtual machine to the backup virtualdisk.

Preferably, the migrating data in the cluster corresponding to thequeried first target value to the second data center includes:

migrating data in the cluster corresponding to the queried first targetvalue to the disaster recovery virtual disk.

Preferably, an initialization step of the binary table includes:

calculating a difference value between the backup virtual disk and thesource virtual disk; and

determining the difference value as an initial label of each cluster ofthe source virtual disk in the binary table.

Preferably, the copying data in the cluster to a second data centerincludes:

if a data copy time point is reached, performing the step of copyingdata in the cluster to a second data center.

According to a second aspect, the present application provides a virtualdisk migration apparatus, applied to a first data center, a sourcevirtual disk corresponding to a virtual machine operating in the firstdata center being divided into a plurality of clusters, the methodincluding:

a copy module, configured to: when a data change occurs in a cluster,update the label of the cluster in a binary table to a first targetvalue; copy data in the cluster to a second data center, and update thefirst target value to a second target value; and

a migration module, configured to: if an instruction for migrating thevirtual machine to the second data center is received, control thevirtual machine to stop operating, query the first target value in thebinary table, and migrate data in the cluster corresponding to thequeried first target value to the second data center.

According to a third aspect, this application provides a virtual diskmigration device, including:

a memory, configured to store a computer program; and

a processor, configured to execute the computer program to implement thevirtual disk migration method disclosed above.

According to a fourth aspect, this application provides a readablestorage medium, storing a computer program, the computer program beingexecuted by a processor to implement the virtual disk migration methoddisclosed above.

As can be seen from the foregoing solutions, the present applicationprovides a virtual disk migration method, applied to a first datacenter, a source virtual disk corresponding to a virtual machineoperating in the first data center being divided into a plurality ofclusters, the method including: when a data change occurs in a cluster,updating the label of the cluster in a binary table to a first targetvalue; copying data in the cluster to a second data center, and updatingthe first target value to a second target value; and if an instructionfor migrating the virtual machine to the second data center is received,controlling the virtual machine to stop operating, querying the firsttarget value in the binary table, and migrating data in the clustercorresponding to the queried first target value to the second datacenter.

As can be seen, in the method, before the virtual machine is migrated tothe second data center, data in the virtual disk is labeled by using thebinary table to distinguish between updated data and unupdated data. Thefirst target value is used for labeling that data is updated. The secondtarget value is used for labeling that data is not updated or is updatedbut has been copied. In the present application, a part of data in avirtual disk corresponding to a virtual machine is copied in advance toa second data center on the basis of a binary table. In this case, whena virtual machine is migrated, only uncopied data in the virtual diskneeds to be migrated, thereby reducing the data migration amount andmigration time, and improving the migration efficiency of a virtual diskand a virtual machine. The part of data copied to the second data centerin advance is updated data in the virtual disk. The data migrated duringthe migration of the virtual machine is data that remains unupdated inthe virtual disk and/or data that is updated but has not been copied tothe second data center.

Correspondingly, the virtual disk migration apparatus and device and thereadable storage medium provided in the present application also havethe foregoing technical effects.

BRIEF DESCRIPTION OF THE DRAWINGS

To describe the technical solutions in the embodiments of thisapplication or the prior art more clearly, the following brieflyintroduces the accompanying drawings required for describing theembodiments or the prior art. Apparently, the accompanying drawings inthe following description show merely embodiments of this application,and a person of ordinary skill in the art may still derive otherdrawings from the provided accompanying drawings without creativeefforts.

FIG. 1 is a flowchart of a first virtual disk migration method accordingto the present application;

FIG. 2 is a flowchart of a second virtual disk migration methodaccording to the present application;

FIG. 3 is a schematic diagram of a virtual disk migration systemaccording to the present application;

FIG. 4 is a schematic diagram of a virtual disk migration apparatusaccording to the present application; and

FIG. 5 is a schematic diagram of a virtual disk migration deviceaccording to the present application.

DETAILED DESCRIPTION OF THE EMBODIMENTS

The following clearly and completely describes the technical solutionsin embodiments of this application with reference to the accompanyingdrawings in embodiments of this application. Apparently, the describedembodiments are some rather than all of the embodiments of the presentapplication. All other embodiments obtained by persons of ordinary skillin the art on the basis of the embodiments of the present applicationwithout creative efforts shall fall within the protection scope of thepresent application.

At present, in an existing migration method, all data in a backup diskneeds to be migrated to a destination end at once. In this case, thedata migration amount is relatively large, resulting in an increasedmigration time and reduced migration efficiency of a virtual disk and avirtual machine. For this, the present application provides a virtualdisk migration solution, so that the migration efficiency of virtualdisks can be improved.

As shown in FIG. 1 , embodiments of the present application provide afirst virtual disk migration method. The method is applied to a firstdata center. A source virtual disk corresponding to a virtual machineoperating in the first data center is divided into a plurality ofclusters. The method includes the following steps.

S101: When a data change occurs in a cluster, update the label of thecluster in a binary table to a first target value.

Specifically, when data in a cluster in a virtual disk is changed, thelabel of the cluster in a binary table is updated to a first targetvalue. The first target value is used for labeling updated data.

S102: Copy data in the cluster to a second data center, and update thefirst target value to a second target value.

Further, data in a cluster with the label of the first target value iscopied to the second data center, that is, updated data is copied to thesecond data center, and at the same time the first target value isupdated to the second target value, the second target value is used forlabeling unupdated data and/or updated but copied data.

S103: Receive an instruction for migrating the virtual machine to thesecond data center.

S104: Control the virtual machine to stop operating, query the firsttarget value in the binary table, and migrate data in the clustercorresponding to the queried first target value to the second datacenter.

When the instruction for migrating the virtual machine to the seconddata center is received, the binary table is searched for the firsttarget value. In this case, the data in the cluster corresponding to thefound first target value includes: unupdated data, updated but copieddata, and data that is updated but has not been copied, that is, theother part of data that needs to be migrated. Therefore, this part ofdata is migrated to the second data center, and migration of all data inthe virtual disk is completed.

In a specific implementation, an initialization step of the binary tableincludes: calculating a difference value between the backup virtual diskand the source virtual disk; and determining the difference value as aninitial label of each cluster of the source virtual disk in the binarytable.

Specifically, the backup virtual disk is also divided into a pluralityof clusters. The clusters in the backup virtual disk correspond one toone to the clusters in the source virtual disk. Therefore, thedifference between the backup virtual disk and the source virtual diskis corresponding differences between the clusters in the backup virtualdisk and the clusters in the source virtual disk. When data stored in acluster in the backup virtual disk is consistent with data stored in acorresponding cluster in the source virtual disk, the difference betweenthe two clusters may be denoted as “0”, or otherwise denoted as “1”. “0”is the second target value, and “1” is the first target value.Therefore, the label of a cluster in the source virtual disk in thebinary table is consistent with the label of a corresponding cluster inthe backup virtual disk in the binary table.

It needs to be noted that a data copy period may be set. When a datacopy time point is reached, data in a cluster with the label of thefirst target value is copied to the second data center. Data is copiedin batches within a preset time period.

As can be seen, in this embodiment, before the virtual machine ismigrated to the second data center, data in the virtual disk is labeledby using the binary table to distinguish between updated data andunupdated data. The first target value is used for labeling that data isupdated. The second target value is used for labeling that data is notupdated or is updated but has been copied. In the present application, apart of data in a virtual disk corresponding to a virtual machine iscopied in advance to a second data center on the basis of a binarytable. In this case, when a virtual machine is migrated, only uncopieddata in the virtual disk needs to be migrated, thereby reducing the datamigration amount and migration time, and improving the migrationefficiency of a virtual disk and a virtual machine.

As shown in FIG. 2 , embodiments of the present application provide asecond virtual disk migration method. The method is applied to a firstdata center. A source virtual disk corresponding to a virtual machineoperating in the first data center is divided into a plurality ofclusters. A second data center is a disaster recovery center of thefirst data center. A disaster recovery virtual disk is disposed in thesecond data center, and is configured to perform disaster recovery ondata in the source virtual disk. The method includes the followingsteps.

S201: When a data change occurs in a cluster, update the label of thecluster in a binary table to a first target value.

S202: Copy data in the cluster to a backup virtual disk in a second datacenter, and update the first target value to a second target value.

S203: Receive an instruction for migrating the virtual machine to thesecond data center.

S204: Control the virtual machine to stop operating, query the firsttarget value in the binary table, and migrate data in the clustercorresponding to the queried first target value to the backup virtualdisk, to enable the second data center to control the virtual machine tooperate on the basis of the backup virtual disk.

In a specific implementation, before the controlling the virtual machineto operate on the basis of the backup virtual disk, the method furtherincludes: migrating a memory resource of the virtual machine to thebackup virtual disk. The backup virtual disk is a backup disk of thedisaster recovery virtual disk.

The migrating data in the cluster corresponding to the queried firsttarget value to the second data center includes: migrating data in thecluster corresponding to the queried first target value to the disasterrecovery virtual disk. That is, when a virtual machine is migrated,remaining data that needs to be migrated is migrated to the disasterrecovery virtual disk, and then data in the disaster recovery virtualdisk is migrated to the backup virtual disk. In this way, the backupvirtual disk stores all data in the source virtual disk. In this case,the backup virtual disk and the disaster recovery virtual disk store thesame data. Therefore, during migration of data in the disaster recoveryvirtual disk to the backup virtual disk, only data that does not existin the backup virtual disk needs to be migrated to the backup virtualdisk. The data that does not exist in the backup virtual disk isremaining data that needs to be migrated during the migration of thevirtual machine.

It needs to be noted that the implementation steps in this embodimentare the same as or similar to those in the foregoing embodiments,reference may be made to each other if necessary, and details are notdescribed again in this embodiment.

As can be seen from above, in this embodiment, before the virtualmachine is migrated to the second data center, data in the virtual diskis labeled by using the binary table to distinguish between updated dataand unupdated data. The first target value is used for labeling thatdata is updated. The second target value is used for labeling that datais not updated or is updated but has been copied. In the presentapplication, a part of data in a virtual disk corresponding to a virtualmachine is copied in advance to a second data center on the basis of abinary table. In this case, when a virtual machine is migrated, onlyuncopied data in the virtual disk needs to be migrated, thereby reducingthe data migration amount and migration time, and improving themigration efficiency of a virtual disk and a virtual machine.

Referring to FIG. 3 , embodiments of this application disclose a virtualdisk migration system. The system includes a data center A (that is, afirst data center) and a data center B (that is, a second data center).The data center A has a plurality of source virtual disks. Each sourcevirtual disk is divided into a plurality of clusters.

The data center B is a disaster recovery center of the data center A.The data center B is provided with a disaster recovery virtual diskcorresponding to the source virtual disk and is provided with a backupdisk, that is, a target virtual disk of the disaster recovery virtualdisk.

In FIG. 3 , 1) periodic disaster recovery, 2) duplication, and 3)storage migration need to be performed. Refer to the following processfor details.

Specifically, data in the source virtual disk may be duplicated to thedisaster recovery virtual disk periodically at 24:00 every day toestablish the backup disk, that is, the target virtual disk of thedisaster recovery virtual disk. In this case, on the second day, thedata center A maintains a binary table. If data in a cluster in avirtual disk in the data center A is changed, the cluster is labeledwith 1 (that is, a first target value) in the binary table; orotherwise, the cluster is labeled with 0 (that is, a second targetvalue) in the binary table. For a cluster labeled with 1, data in thecluster is copied to a backup virtual disk (that is, the target virtualdisk in FIG. 3 ) of the data center B in time. After copying iscompleted, the cluster is labeled with 0.

If the data center A triggers a virtual machine migration procedure onthe second day, the data center A controls a to-be-migrated virtualmachine to stop operating, and searches the binary table for clusterslabeled with 1, to further migrate data in the clusters labeled with 1to the target virtual disk in the data center B. In this case, thetarget virtual disk stores all data in a source virtual diskcorresponding to a current virtual machine. In this case, data in thedisaster recovery virtual disk has been stored in the target virtualdisk. Therefore, the data in the disaster recovery virtual disk may becleared to wait till 24:00 on the second day to perform disasterrecovery on data in another source virtual disk.

Further, the data center B migrates a memory resource of a virtualmachine corresponding to a source virtual disk in time to completemigrate of the virtual machine.

It needs to be noted that the implementation steps in this embodimentare the same as or similar to those in the foregoing embodiments.Therefore, details are not described herein again in this embodiment.Reference may be made to each other if necessary, and details are notdescribed again in this embodiment.

In this embodiment, during migration of a virtual disk, it is notnecessary to perform full copy on the virtual disk, thereby reducing themigration time of a virtual machine and improving the migrationefficiency of a virtual disk and a virtual machine.

A virtual disk migration apparatus provided in the embodiments of thepresent application is described below. For the virtual disk migrationapparatus described below and the virtual disk migration methoddescribed above, reference may be made to each other.

As shown in FIG. 4 , embodiments of the present application provide avirtual disk migration apparatus. The method is applied to a first datacenter. A source virtual disk corresponding to a virtual machineoperating in the first data center is divided into a plurality ofclusters. The apparatus includes:

a copy module 401, configured to: when a data change occurs in acluster, update the label of the cluster in a binary table to a firsttarget value; and copy data in the cluster to a second data center, andupdate the first target value to a second target value; and

a migration module 402, configured to: if an instruction for migratingthe virtual machine to the second data center is received, control thevirtual machine to stop operating, query the first target value in thebinary table, and migrate data in the cluster corresponding to thequeried first target value to the second data center.

In a specific implementation, the second data center is a disasterrecovery center of the first data center; and if a corresponding backupvirtual disk is disposed for a disaster recovery virtual disk in thesecond data center,

the copy module is specifically configured to:

copy data in the cluster to the backup virtual disk, a disaster recoveryvirtual disk is disposed in the second data center, and is configured toperform disaster recovery on data in the source virtual disk; and

correspondingly, the migration module is specifically configured to:

migrate data in the cluster corresponding to the queried first targetvalue to the backup virtual disk.

In a specific implementation, the second data center is specificallyconfigured to migrate a memory resource of the virtual machine to thebackup virtual disk, and control the virtual machine to operate on thebasis of the backup virtual disk.

In a specific implementation, the migration module is specificallyconfigured to:

migrate data in the cluster corresponding to the queried first targetvalue to the disaster recovery virtual disk.

In a specific implementation, the virtual disk migration apparatusfurther includes a binary table initialization module, and the binarytable initialization module includes:

a calculation unit, configured to calculate a difference value betweenthe backup virtual disk and the source virtual disk; and

a determination unit, configured to determine the difference value as aninitial label of each cluster of the source virtual disk in the binarytable.

In a specific implementation, the copy module is specifically configuredto:

if a data copy time point is reached, perform the step of copying datain the cluster to a second data center.

For a more specific working process of the modules and units in thisembodiment, reference may be made to the corresponding content disclosedin the foregoing embodiments. Details are not described herein again.

As can be seen, this embodiment provides a virtual disk migrationapparatus. The apparatus can reduce the data migration amount andmigration time, and improve the migration efficiency of a virtual diskand a virtual machine.

A virtual disk migration device provided in the embodiments of thepresent application is described below. For the virtual disk migrationdevice described below and the virtual disk migration method andapparatus described above, reference may be made to each other.

Referring to FIG. 5 , an embodiment of the present application disclosesa virtual disk migration device, including:

a memory 501, configured to store a computer program; and

a processor 502, configured to execute the computer program to implementthe method disclosed in any foregoing embodiment.

A readable storage medium provided in the embodiments of the presentapplication is described below. For the readable storage mediumdescribed below and the virtual disk migration method, apparatus anddevice described above, reference may be made to each other.

A readable storage medium is configured to store a computer program, thecomputer program being executed by a processor to implement the virtualdisk migration method disclosed in the foregoing embodiments. Forspecific steps of the method, reference may be made to the correspondingcontent disclosed in the foregoing embodiments. Details are notdescribed herein again.

“First”, “second”, “third”, “fourth”, and the like (if exist) involvedin the present application are only used to distinguish between similarobjects, but are not used to describe a specific order or time sequence.It should be understood that the data thus used are interchangeable inappropriate circumstances and that the embodiments described herein canbe implemented in other sequences than the content illustrated ordescribed. In addition, the terms “include”, “include”, and anyvariation of such terms in the description and claims of the presentapplication is intended to cover a non-exclusive inclusion. For example,a process, method or device that includes a series of steps or units notonly includes those steps or units specified expressly, but alsoincludes other steps or units that are not specified expressly or areinherent to the process, method or device.

It needs to be noted that in the present application, description of“first”, “second”, and the like are used only for description, but arenot intended to indicate or imply relative importance or implicitlyspecify a quantity of indicated technical features. Therefore, thefeatures limited by “first” and “second” may explicitly or implicitlyinclude at least one such feature. In addition, the technical solutionsbetween the various embodiments can be combined with each other on thebasis of that a combination can be implemented by a person of ordinaryskill in the art. When a combination of technical solutions encounters acontradiction or cannot be implemented, it should be considered thatthis combination of technical solutions does not exist and does not fallwithin the scope of protection that the present application seeks toprotect.

All embodiments are described in the present invention by using theprogressive method. Each embodiment describes only the difference fromother embodiments. For the same or similar parts among all embodiments,reference may be made to the relevant parts.

Steps of methods or algorithms described in the embodiments disclosed inthis specification may be directly implemented by hardware, a softwaremodule executed by a processor, or a combination thereof. The softwaremodule may reside in a random access memory (RAM), a memory, a read-onlymemory (ROM), an electrically programmable ROM, an electrically erasableprogrammable ROM, a register, a hard disk, a removable disk, a CD-ROM,or any other form of readable storage medium known in the art.

Although the principle and implementation manners of the presentapplication are described by using specific examples in thisspecification, descriptions of the embodiments are merely intended tohelp understand the methods and core idea of the present application. Inaddition, for a person of ordinary skill in the art, according to theidea of the present application, changes may be made to the specificimplementation and the scope of application. In summary, the content ofthis specification should not be construed as a limitation to thepresent application.

1. A virtual disk migration method, applied to a first data center, asource virtual disk corresponding to a virtual machine operating in thefirst data center being divided into a plurality of clusters, the methodcomprising: when a data change occurs in a cluster, updating the labelof the cluster in a binary table to a first target value; copying datain the cluster to a second data center, and updating the first targetvalue to a second target value; and if an instruction for migrating thevirtual machine to the second data center is received, controlling thevirtual machine to stop operating, querying the first target value inthe binary table, and migrating data in the cluster corresponding to thequeried first target value to the second data center.
 2. The virtualdisk migration method according to claim 1, wherein the second datacenter is a disaster recovery center of the first data center; and if acorresponding backup virtual disk is disposed for a disaster recoveryvirtual disk in the second data center, the copying data in the clusterto a second data center comprises: copying the data in the cluster tothe backup virtual disk, wherein the disaster recovery virtual disk isdisposed in the second data center and is configured to perform disasterrecovery on data in the source virtual disk; and correspondingly, themigrating data in the cluster corresponding to the queried first targetvalue to the second data center comprises: migrating data in the clustercorresponding to the queried first target value to the backup virtualdisk.
 3. The virtual disk migration method according to claim 2, whereinafter the migrating data in the cluster corresponding to the queriedfirst target value to the backup virtual disk, the method furthercomprises: controlling, by the second data center, the virtual machineto operate on the basis of the backup virtual disk.
 4. The virtual diskmigration method according to claim 3, wherein before the controllingthe virtual machine to operate on the basis of the backup virtual disk,the method further comprises: migrating a memory resource of the virtualmachine to the backup virtual disk.
 5. The virtual disk migration methodaccording to claim 2, wherein the migrating data in the clustercorresponding to the queried first target value to the second datacenter comprises: migrating data in the cluster corresponding to thequeried first target value to the disaster recovery virtual disk.
 6. Thevirtual disk migration method according to claim 2, wherein aninitialization step of the binary table comprises: calculating adifference value between the backup virtual disk and the source virtualdisk; and determining the difference value as an initial label of eachcluster of the source virtual disk in the binary table.
 7. The virtualdisk migration method according to claim 1, wherein the copying data inthe cluster to a second data center comprises: if a data copy time pointis reached, performing the step of copying data in the cluster to asecond data center.
 8. (canceled)
 9. A virtual disk migration device,comprising: a memory, configured to store a computer program; and aprocessor, configured to execute the computer program to implement thevirtual disk migration method according to claim
 1. 10. A readablestorage medium, storing a computer program, the computer program beingexecuted by a processor to implement the virtual disk migration methodaccording to claim
 1. 11. The virtual disk migration method according toclaim 3, wherein an initialization step of the binary table comprises:calculating a difference value between the backup virtual disk and thesource virtual disk; and determining the difference value as an initiallabel of each cluster of the source virtual disk in the binary table.12. The virtual disk migration method according to claim 4, wherein aninitialization step of the binary table comprises: calculating adifference value between the backup virtual disk and the source virtualdisk; and determining the difference value as an initial label of eachcluster of the source virtual disk in the binary table.
 13. The virtualdisk migration method according to claim 5, wherein an initializationstep of the binary table comprises: calculating a difference valuebetween the backup virtual disk and the source virtual disk; anddetermining the difference value as an initial label of each cluster ofthe source virtual disk in the binary table.